package com.berchen.common;

import lombok.Data;
import org.springframework.util.StringUtils;

@Data
public class PageModel {

    private Integer num;
    private Integer size;
    // mybatis 里面用$
    private String orderStr;
    private String order;   // desc asc

    /**
     * 设置num的值 进行分页必须的
     */
    public void updateNum() {
        num = num <= 1 ? 0 : (num -1)* size;
    }

    /**
     * 检查排序是否为 desc asc
     * @return
     */
    public boolean checkOrder(){

        return StringUtils.isEmpty(order)?true: "desc".equalsIgnoreCase(order)||"asc".equalsIgnoreCase(order);
    }

}
